import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:share_fit/app/components/back_btn_icon.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'logic.dart';

class TakePicSettingPage extends StatelessWidget {
  TakePicSettingPage({Key? key}) : super(key: key);

  final logic = Get.find<TakePicSettingLogic>();
  final state = Get.find<TakePicSettingLogic>().state;

  final storage = GetStorage();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: BackBtnIcon(onTap: () => Get.back()),
        centerTitle: true,
        title: Text(LocaleKeys.settings_camera_remote.ts, style: TextStyle(fontSize: 54.sp)),
      ),
      body: Container(
        padding: EdgeInsets.only(top: 150.h),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [Image.asset('assets/images/device/camera_1.png', width: 294.w, height: 242.w)],
            ),
            Container(
                margin: EdgeInsets.only(top: 128.h),
                padding: EdgeInsets.symmetric(horizontal: 50.w),
                constraints: BoxConstraints.expand(width: 1040.w, height: 175.h),
                decoration: BoxDecoration(color: Colors.white70.withOpacity(0.8), borderRadius: BorderRadius.circular(50.r)),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Obx(() => Text(
                        state.openShakeToTakePic.value
                            ? LocaleKeys.settings_camera_remote_open_text.ts
                            : LocaleKeys.settings_camera_remote_close_text.ts,
                        style: TextStyle(fontSize: 42.sp))),
                    Obx(
                      () => Transform.scale(
                        scaleY: 0.7,
                        scaleX: 0.7,
                        child: CupertinoSwitch(
                          activeColor: ColorConst.accentColor,
                          value: state.openShakeToTakePic.value,
                          onChanged: (value) {
                            logic.sendCameraPermission(value);
                          },
                        ),
                      ),
                    ),
                  ],
                ))
          ],
        ),
      ),
    );
  }
}
